<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	  <%@include file="/res/include/base-head.jsp"%>
	  <%@include file="/res/include/jquery-easyui.jsp"%>
	<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/circle/cirlceBase.js"></script>
  </head>
  <body>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'north',border:false,split:false">
	    	<form id="query-form" class="search_form clearfix">
				<p class="cl"></p>
	            <dl>
					<dt>圈子名称：</dt>
					<dd>
						<input name="search" id="search" type="text" class="txt" maxlength="16"/>
					</dd>
				</dl>
				<dl>
	            	<dt>创建时间：从</dt>
	                <dd>
		                <input name="startAtStr" id="startAtStr" type="text" class="txt easyui-datetimebox" maxlength="19"/> 到 
		                <input name="endAtStr" id="endAtStr" type="text" class="txt easyui-datetimebox" maxlength="19"/>
	                </dd>
	            </dl>
				<dl>
					<dt>审核状态：</dt>
					 <dd>
	                	<select name="auditStatus" id="auditStatus" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                		<option value="1">待审核</option>
	                		<option value="2">审核通过</option>
	                		<option value="3">审核不通过</option>
	                	</select>
	                </dd>
				</dl>
				<dl>
	                <dt>是否推荐：</dt>
	                <dd>
	                	<select name="isRecommend" id="isRecommend" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                		<option value="1">是</option>
	                		<option value="2">否</option>
	                	</select>
	                </dd>
	            </dl>
				
	            <p class="search_form_btn">
	            	<input type="button" value="搜索" class="icon_serach" onclick="admin.cirlceBase.query()" />
	            </p>
	            
	        </form>
	  	</div>
	    <div data-options="region:'center',border:false">
		    <table id="datagrid" data-options="url:'${pageContext.request.contextPath}/circle/base/list',toolbar:'#toolbar'">
				<thead>
  					<tr>
						<th data-options="field:'name',width:120,align:'center'">名称</th>
						<th data-options="field:'remark',width:120,align:'left'">简介</th>
						<th data-options="field:'cityName',width:100,align:'center' ">所在城市</th>
						<th data-options="field:'communityName',width:100,align:'center' ">创始社区</th>
						<th data-options="field:'extCommunityNames',width:100,align:'center' ">扩展社区</th>
						<th data-options="field:'creatorName',width:100,align:'center' ">圈主</th>
						<th data-options="field:'strNewAt',width:120,align:'center'">创建时间</th>
						<th data-options="field:'topicCount',width:60,align:'center'">话题数量</th>
						<th data-options="field:'memberCount',width:60,align:'center'">成员数量</th>
						<th data-options="field:'pv',width:60,align:'center'">点击数</th>
						<th data-options="field:'type',width:60,align:'center',formatter:formatType">类型</th>
						<th data-options="field:'isRecommend',width:60,align:'center',formatter:formatRecommendStatus">是否推荐</th>
						<th data-options="field:'recommendOidx',width:60,align:'center',formatter:formatRecommendOidx">推荐位</th>
			            <th data-options="field:'auditStatus',width:100,align:'center',formatter:formatAuditStatus">审核状态</th>
			            <th data-options="field:'tagName',align:'center',width:300,formatter:formatOperation4Audit">操作</th>
					</tr>
				</thead>
			</table>
	  	</div>
	</div>

	<script>
		function formatOperation4Audit(value,row,index) {
			var type = row.type;
			var auditStatus = row.auditStatus;//圈子审核状态:1-待审核;2-审核通过;3-审核不通过
			var l_html = '';
			var isRecommend = row.isRecommend;//是否推荐:1-是 2-否
			var isLottery = row.isLottery;//1:可抽奖；2:不可抽奖
			l_html += '<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.detail('+row.id+')">查看</a>';
			if(type=="1"){//后台可以修改官方圈子
				l_html += '|<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.toUpdate('+row.id+')">修改</a>';
			}
			if(isRecommend=="1"){//已推荐
				l_html += '|<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.unRecommend('+row.id+')">取消推荐</a>';
			}else if(auditStatus=="2"){//未推荐且审批通过的圈子才能推荐
				l_html += '|<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.recommend('+row.id+')">推荐</a>';
			}
			if(auditStatus=="1"){//待审核
				l_html += '|<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.auditPass('+row.id+')">通过</a>';
				l_html += '|<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.auditNotPass('+row.id+')">不通过</a>';
			}else if(auditStatus=="2"){//审核通过
				l_html += '|<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.undoAudit('+row.id+')">取消审批</a>';
			}else if(auditStatus=="3"){//审核不通过
				l_html += '|<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.undoAudit('+row.id+')">取消审批</a>';
			}
			if(isLottery==1){
				l_html += '|<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.downLottery('+row.id+')">取消抽奖</a>';
			}else if(isLottery==2){
				l_html += '|<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.upLottery('+row.id+')">加入抽奖</a>';
			}
			return l_html;
		}
		
		function formatOperation(value,row,index) {
			var type = row.type;
			var isRecommend = row.isRecommend;//是否推荐:1-是 2-否
			var auditStatus = row.auditStatus;//圈子审核状态:1-待审核;2-审核通过;3-审核不通过
			var l_html = '';
			l_html += '<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.detail('+row.id+')">查看</a>';
			if(type=="1"){//后台可以修改官方圈子
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.toUpdate('+row.id+')">修改</a>';
			}
			if(isRecommend=="1"){//已推荐
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.unRecommend('+row.id+')">取消推荐</a>';
			}else if(auditStatus=="2"){//未推荐且审批通过的圈子才能推荐
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.cirlceBase.recommend('+row.id+')">推荐</a>';
			}
			return l_html;
		}
		function formatType(value,row,index) {
			var type = row.type;
			if(type=="1"){
				return '【官方】';
			}else if(type=="2"){
				return '【民间】';
			}else if(type=="3"){
				return '【平台】';
			}else if(type=="4"){
				return '【社区】';
			}
		}
		
		function formatRecommendStatus(value,row,index) {
			var isRecommend = row.isRecommend;//是否推荐:1-是 2-否
			if(isRecommend=="1"){
				return '【已推荐】';
			}
		}
		
		function formatAuditStatus(value,row,index) {
			var auditStatus = row.auditStatus;//圈子审核状态:1-待审核;2-审核通过;3-审核不通过
			if(auditStatus=="1"){
				return '待审核';
			}else if(auditStatus=="2"){
				return '审核通过';
			}else if(auditStatus=="3"){
				return '审核不通过';
			}
		}
		function formatRecommendOidx(value,row,index) {
			var isRecommend = row.isRecommend;//是否推荐:1-是 2-否
			if(isRecommend=="1"){
				return row.recommendOidx;
			}else{
				return "";
			}
		}
		
	</script>
  </body>
</html>
